package tech.aistar.service.center;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import tech.aistar.entity.UserInfo;

import java.util.List;

/**
 * Created by 23827 on 2019/9/28.
 */
@Service
public interface IUserInfoService {
    //    查询所有
    @Select("select * from user_info")
    List<UserInfo> findAll();

    //    通过用户名查找
    @Select("select * from user_info where name=#{value}")
    UserInfo findByName(String name);


    //    更改信息

    void updateUserInfo(UserInfo userInfo);

    //    添加
    @Insert("insert into user_info(user_id,name,id_card,picture_id,address_id,tel_number,intro,comment_id,grade,status,balance)values(#{userId},#{name},#{idCard},#{pictureId},#{addressId},#{telNumber},#{intro},#{commentId},#{grade},#{status},#{balance})")
    UserInfo insertUserInfo(UserInfo userInfo);

    //    通过id查询
    @Select("select tel_number from user_info where id=#{value}")
    List<UserInfo> getById(Integer id);


    //通过id查找用户姓名

    @Select("select name from user_info where id = #{value}")
    UserInfo findById(Integer id);


    @Select("select * from user_info where id = #{value}")
    UserInfo ById(Integer id);
    //个人中心信息展示 - 第三方实体类
//     CenterVo selectByUserId(Integer user_id);


    //通过id修改电话号码
    @Update("update user_info set tel_number = 18809075632 where id = #{value}")
    UserInfo updateById(UserInfo userInfo);


    @Select("select * from user_info where user_id=#{value}")
    UserInfo getByUserId(Integer id);

    //通过id查找电话号码
    @Select("select tel_number from user_info where id = #{value} ")
    UserInfo findNumberById(Integer id);

    //    修改部分
    UserInfo updateOne(UserInfo userInfo);
}
